package com.approval.approvalapp.util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
 * Created by louyulin on 2019/3/18.
 * glide 二次封装
 */

public class GlideLoader {
    private static GlideLoader mInstance;

    private GlideLoader() {
    }

    public static GlideLoader getmInstance() {
        synchronized (GlideLoader.class) {
            if (mInstance == null) {
                synchronized (GlideLoader.class) {
                    mInstance = new GlideLoader();
                }
            }
        }
        return mInstance;
    }

    public void displayImage(String imageUrl, Context context, ImageView imageView) {
        Glide.with(context)
                .load(imageUrl)
                .thumbnail(0.1f) //先加载缩略图 然后在加载全图
                .diskCacheStrategy(DiskCacheStrategy.ALL) //设置缓存策略 ALL:缓存源资源和转换后的资源
                .into(imageView);
    }
}
